clear; clc;
load('data/recsys/movielen100k.mat');

para.tau = 1.01;
para.maxTime = 3600;
[row, col, val] = find(data);

val = val - mean(val);
val = val/std(val);

idx = randperm(length(val));

traIdx = idx(1:floor(length(val)*0.5));
tstIdx = idx(ceil(length(val)*0.5): end);

clear idx;

traData = sparse(row(traIdx), col(traIdx), val(traIdx));
traData(size(data,1), size(data,2)) = 0;

%% start testing
para.maxIter = 5000;
para.decay = 0.9;
para.tol = 1e-1;

for i = 1:3
    
para.regType = i;
para.maxR = 10;

switch(i)
    case 1
        lambda = 20;
        theta1 = lambda*2;
    case 2
        lambda = 1000;
        theta1 = sqrt(lambda);
    case 3
        lambda = 20;
        theta1 = 1;
end


%% GIST
t = tic;
para.acc = 0;
para.speedup = 1;
% [ U, S, V, out{1,i} ] = GISTMatComp( traData, lambda, theta1, para);
[ U, S, V, out{1,i} ] = FastMatComp( traData, lambda, theta1, para);
Time(1,i) = toc(t);
RMSE(1,i) = MatCompRMSE( U, V, S, row(tstIdx), col(tstIdx), val(tstIdx));

clear U S V t;

t = tic;
para.acc = 1;
% [ U, S, V, out{2,i} ] = GISTMatComp( traData, lambda, theta1, para);
[ U, S, V, out{2,i} ] = FastMatCompAcc( traData, lambda, theta1, para);
Time(2,i) = toc(t);
RMSE(2,i) = MatCompRMSE( U, V, S, row(tstIdx), col(tstIdx), val(tstIdx));

clear U S V t;

end


